import os,sys

new_file_name = sys.argv[1]#'ChangeName'#sys.argv[1]
current_path = os.path.dirname(os.path.abspath(__file__))
current_path = os.path.join(os.path.dirname(current_path), 'cmake')
file_path_in = os.path.join(current_path, 'TutorialRecommendedBackendConfig.cmake.in')
file_path_out = file_path_in.replace('TutorialRecommended', new_file_name)

new_file_name_upper = new_file_name.upper()
new_file_name_lower = new_file_name.lower()
replace_list = ['TUTORIALRECOMMENDED', 'TutorialRecommended', 'recommended']

with open(file_path_in, 'r') as f:
    context = f.read()

context = context.replace(replace_list[0], new_file_name_upper)
context = context.replace(replace_list[1], new_file_name)
context = context.replace(replace_list[2], new_file_name_lower)

with open(file_path_out, 'w') as f:
    f.write(context)

os.remove(file_path_in)

print('finish')
